<script setup>
import { ref, onMounted } from 'vue'
import { listMyTeamSpaceAPI } from '@/api/spaceUserAPI'

const teamSpaces = ref([])

onMounted(() => {
  listMyTeamSpaceAPI().then((res) => {
    teamSpaces.value = res.data
    console.log(res)
  })
})
</script>

<template>
  <div class="space-detail-layout">
    <el-container class="space-detail-container">
      <el-aside width="240px" class="space-detail-aside">
        <el-menu router :default-active="$route.path" class="custom-menu">
          <h3>个人空间</h3>
          <el-menu-item index="/space_detail/private_space_detail" class="menu-item">
            <Icons name="icon-mn_kongjian" color="#2563eb" size="20" />
            <span>我的空间</span>
          </el-menu-item>
          <!-- 团队空间，多个团队，发送请求： /space_detail/team_space_detail spaceId 和 spaceName-->
          <!-- 使用el-sub-menu -->
          <h3>团队空间</h3>
          <el-menu-item
            v-for="(item, index) in teamSpaces"
            :key="index"
            :index="`team_space_detail?spaceId=${item.space.id}&spaceName=${item.space.spaceName}`"
            class="menu-item"
          >
            <Icons name="icon-mn_kongjian" color="#2563eb" size="20" />
            <span>{{ item.space.spaceName }}</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main class="space-detail-main">
        <div class="space-detail-main-content">
          <router-view></router-view>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<style scoped>
/* 基础布局样式 */
.space-detail-layout {
  width: 100%;
  min-height: 100vh;
  background-color: #f8fafc;
  color: #1e293b;
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.space-detail-container {
  height: 100vh;
  width: 100%;
}

/* 侧边栏样式 - 明亮蓝色风格 */
.space-detail-aside {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #2563eb;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
  transition: all 0.3s ease;
  border-right: 1px solid #bfdbfe;
}

/* 菜单样式 */
.custom-menu {
  background-color: transparent;
  border-right: none;
  padding-top: 30px;
}
h3 {
  font-size: 16px;
  font-weight: 500;
  color: #2563eb;
  margin-bottom: 12px;
  padding-left: 12px;
  border-left: 4px solid #2563eb;
  margin-top: 12px;
}

.menu-item {
  height: 56px;
  line-height: 56px;
  margin: 0 12px 6px;
  border-radius: 8px;
  color: #3b82f6;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.25s ease;
  position: relative;
}

/* 明亮风格菜单交互效果 */
.menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background-color: #2563eb;
  transform: scaleY(0);
  transition: transform 0.25s ease;
}

.menu-item:hover {
  background-color: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  padding-left: 4px;
}

.menu-item:hover::before {
  transform: scaleY(1);
}

/* 激活状态样式 */
.menu-item.is-active {
  background-color: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.menu-item.is-active::before {
  transform: scaleY(1);
  background-color: #2563eb;
}

.menu-item span {
  margin-left: 14px;
  letter-spacing: 0.2px;
}

/* 主内容区域样式 */
.space-detail-main {
  padding: 24px;
  overflow-y: auto;
  background-color: #f8fafc;
}

.space-detail-main-content {
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
  min-height: calc(100vh - 96px);
  padding: 28px;
  transition: all 0.3s ease;
  border: 1px solid #e2e8f0;
}

.space-detail-main-content:hover {
  box-shadow: 0 5px 20px rgba(59, 130, 246, 0.1);
  border-color: #bfdbfe;
}

/* 滚动条美化 */
.space-detail-main::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.space-detail-main::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.space-detail-main::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

.space-detail-main::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .space-detail-aside {
    width: 64px !important;
  }

  .menu-item span {
    display: none;
  }

  .menu-item {
    justify-content: center;
    padding: 0;
  }

  .menu-item::before {
    display: none;
  }

  .space-detail-main {
    padding: 12px;
  }

  .space-detail-main-content {
    padding: 16px;
    min-height: calc(100vh - 64px);
  }
}
</style>
